(******************************************************)
(*													  *)
(*	Main program to test Dragon method.				  *)
(*	This version includes MPW performance analyzer	  *)
(*	calls.											  *)
(*													  *)
(*	Written in SemperSoft Modula-2 v.1.1.2			  *)
(*													  *)
(*	Allen Stenger	August 1989  					  *)
(*													  *)
(******************************************************)

MODULE DrawDragon;

FROM InOut			IMPORT WriteLong, WriteString, Read;
FROM InsideMac		IMPORT TickCount;
FROM Perform		IMPORT InitPerf, PerfControl, 
							PerfDump, TermPerf, 
							TP2PerfGlobals;
FROM DragonModule	IMPORT Dragon;
FROM Pen			IMPORT Home;

	
VAR
	oldTime,
	newTime		:	LONGINT;
	ch 			: 	CHAR;
	thePerfGlobals : TP2PerfGlobals;
	junk : BOOLEAN;

BEGIN
	(* Initialize performance measurement *)
	thePerfGlobals := NIL;
	IF InitPerf( 	
				thePerfGlobals, (* measurement block *)
				20,			(* sample interval *)
				8,			(* bucket size *)
				TRUE,		(* measure ROM *)
				TRUE,		(* measure application *)
				"CODE",		(* resource type to 
									measure *)
				0,			(* ROM ID *)
				'',			(* ROM name *)
				FALSE,		(* measure RAM misses *)
				0,0,0		(* for RAM misses *)
			)
	THEN
	ELSE WriteString( "Initialization failed" );
	END; (* IF *)
	
	(* Start performance measurement *)
	junk := PerfControl( thePerfGlobals, TRUE );
	
	oldTime := TickCount();

	Home;
	Dragon( 8 );
	
	newTime := TickCount();
	
	(* End performance measurement *)
	IF 0 = PerfDump( 	thePerfGlobals,
				"DrawDragon.dump",	(* dump file for 
										results *)
				FALSE,				(* histograms *)
				0					(* histograms *)
			)
	THEN
	ELSE WriteString( "PerfDump failed" );
	END; (* IF *)
	TermPerf( thePerfGlobals );
	
	WriteString( "Run time is " );
	WriteLong( newTime - oldTime, 6 );
	WriteString( " -- press space to exit " );
	Read( ch );
END DrawDragon.